<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:p="http://primefaces.prime.com.tr/ui"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:f="http://java.sun.com/jsf/core">  
   
    <h:head>
        <title>:.Medral Tecnologia Penha.:</title>
    </h:head>
    
     <h:body style="background-color: paleturquoise">
         <ui:include src="/paginas/menu.xhtml"/> 
        
    <p:growl id="avisos" showDetail="true" life="3000" />  

    <p:fieldset legend="CADASTRO DE VEÍCULOS:" toggleable="true">  
    <h:form> 
        
        <h:panelGrid columns="2">
        <h:outputText value="Data do Cadastro:" />  
        <p:calendar value="#{VeiculosBean.veiculos.dataCadastro}" maxlength="12" size="10"/> 
        </h:panelGrid>
        
        <h:panelGrid columns="4">
        <h:outputText value="Matrícula:" />  
        <p:inputMask mask="99.999" value="#{VeiculosBean.veiculos.matricula}" maxlength="5" size="7"/>     
        
        <h:outputText value="Nome do Encarregado:" />  
        <p:inputText id="nomeEnc" value="#{VeiculosBean.veiculos.nomeEnc}" maxlength="30" size="38"/>
        </h:panelGrid>          
        
        <h:panelGrid columns="10">
        <h:outputText value="Placa do Veículo:" />  
        <p:inputMask mask="aaa-9999" value="#{VeiculosBean.veiculos.placa}" maxlength="7" size="8"/>
       
        <h:outputText value="Marca:" />  
        <p:inputText id="marca" value="#{VeiculosBean.veiculos.marca}" maxlength="7" size="8"/>
        
        <h:outputText value="Modelo:"/>
        <p:inputText id="modelo" value="#{VeiculosBean.veiculos.modelo}" maxlength="7" size="8"/>
        
        <h:outputText value="Ano:"/>
        <p:inputText id="ano" value="#{VeiculosBean.veiculos.ano}" maxlength="4" size="6"/>
        
        <h:outputText value="Status:"/>
        <p:inputText id="status" value="#{VeiculosBean.veiculos.status}" maxlength="7" size="7"/>
        </h:panelGrid>        

         <p:separator style="width: 100%; height: 3px" />  

        <p:commandButton value="CADASTRAR" actionListener="#{VeiculosBean.veiculos.cadastrar}" type="submit" update="avisos,mensagens"/>
        <p:commandButton value="LIMPAR CAMPOS" actionListener="#{VeiculosBean.veiculos.limpar}" type="reset" /> 
        
        </h:form>  
        </p:fieldset>  
    
   <p:fieldset legend="LISTA GERAL:" toggleable="true">  
   <h:form id="form">

                <p:growl id="msgs" />

                 <p:outputPanel id="books">
                    <p:dataTable id="booksTable" value="#{bookBean.books}" var="book">

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Data" />
                            </f:facet>
                            <h:outputText value="#{book.data}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Nome" />
                            </f:facet>
                            <h:outputText value="#{book.nomeEnc}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                             <h:outputText value="Matrícula" />
                            </f:facet>
                            <h:outputText value="#{book.matrícula}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Placa" />
                            </f:facet>
                            <h:outputText value="#{book.placa}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Marca" />
                            </f:facet>
                            <h:outputText value="#{book.marca}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Modelo" />
                            </f:facet>
                            <h:outputText value="#{book.modelo}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                 <h:outputText value="Ano" />
                            </f:facet>
                            <h:outputText value="#{book.ano}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Operação" />
                            </f:facet>
                            
                            <p:commandLink value="Excluir" update=":form:books" process=":form:books">
                                <p:collector value="#{book}"
                                             removeFrom="#{bookBean.books}" />
                            </p:commandLink>
                        </p:column>

                    </p:dataTable>
                </p:outputPanel>

            </h:form>  
        </p:fieldset>    

        <p:messages id="mensagens" showDetail="true" />  

    </h:body>  

 </html> 

 